<link rel="icon" href="favicon.jpg" type="image/gif" sizes="16x16" />


<?php
$a = session_id();if(empty($a)) session_start();
//require_once(dirname(__FILE__)."class/autentificare.php");
require_once dirname(__FILE__).'/class/functions.php';

if( !isset($_SESSION['logat']) )
    $_SESSION['logat']="NU";


if(!isset($_GET["actiune"]))
    $_GET["actiune"]='';

?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="icon" href="favicon.jpg" type="image/gif" sizes="16x16" /> 
        <link rel="stylesheet" type="text/css" href="./style/style.css" />
        <title>Rezervari Sali</title>
    </head>
<body>
   <? header_out(); 
   footer();
        ?>
        <div id="content">
            <div id="content_inside">
                    <div id="content_inside_sidebar">
                        <ul>
                            <li><a href ="index.php"> Home</a><br />
                            </li><li><a href ="cauta.php"> Cautare</a><br /></li>
                            <li><a href ="rezervare.php"> Rezervari</a><br /></li>                   
                                           
                         </ul>
                                 
                    </div>
            <div id="content_inside_main">
<?


switch ($_GET['actiune'])
{
    case '': 
        if( $_SESSION['logat'] == "user" && is_logat()==1 )
            echo "Sunteti logat ca user normal <br/>";
        else 
            if( $_SESSION['logat'] == "admin" && is_logat()==1)
                echo "Sunteti logat ca admin <br/>";
            else
                die("Nu aveti acces pe aceasta pagina");
        
        echo "Cauta in cartea de telefon dupa nume sau numar de telefon";
  ?>      
        <form name="logare" action="cauta.php?actiune=cautare" method=post>
                    Nume: <input type="text" name="nume" value=""/> <br/>
                    Prenume: <input type="text" name="prenume" value=""/> <br/>
                    sau<br/>
                    Numar telefon : <input type="text" name="tel" value=""/> <br/>               
                    <a href="#" class="grey-button pcb"><span><input type="Submit" value="Cauta"></input></span></a> <br/> <br/>                    
              </form>
  <?
        
        
        break;
    
    case 'cautare': 
        mysql_safer();
        
        if(!isset($_POST['nume']) && !isset($_POST['prenume'])&& !isset($_POST['tel']) )
            die("Completati cel putin un camp");
        
        $nume = $_POST['nume']." ". $_POST['prenume'];
        $sql_cauta = "Select nume, telefon from carte_telefon WHERE ";
        if((isset($_POST['nume'])&&strlen($_POST['nume'])>1) || (isset($_POST['prenume'])&&strlen($_POST['nume'])>1)) $sql_cauta.="nume like '%".$nume."%'";
        if(isset($_POST['tel']) && strlen($_POST['tel'])>1) $sql_cauta.="telefon = '".$_POST['tel']."'";
       // echo $sql_cauta;
        $rezultat = $class_db->q($sql_cauta);
        if(!$rezultat)
            die ("Nu exista acest nume/nr tel in cartea de telefon");
        else
        {
            while( $row =  mysql_fetch_array($rezultat) )
                echo $row['nume']." ".$row['telefon']."<br/>";
            
        }
        
        break;
        
        
    case 'delogare': 
        if( session_destroy() == true )
            echo 'Sesiune distrusa! <br /> <a href="index.php">Go back </a> ';
            setcookie("pu", '', time()-3600, '/');
        break;
}


?>
</body>



</html>